<template>
  	<view class="index-page">
     	<cu-custom bgColor="bgmain" :isBack="true">
			<view slot="content">店员管理</view>
		</cu-custom>
		<block v-for="(item,index) in list" :key="index">
			<view class="userInfo row">
				<image
					class="avatar"
					:src="item.avatar"
					mode="scaleToFill"
				/>
				<view class="name">{{ item.name }}</view>
				<view class="right row" >
					<view class="cuIcon-edit edit"  @click="go('./editor?b_id=' + query.b_id + '&s_id=' + query.s_id+'&id='+item.id)"></view>
					<view class="cuIcon-delete margin-left  del"  @click="del(item.id,item.u_id)"></view>
				</view>
			</view>
		</block>
		
		<view class="submit row" @click="go('./editor?b_id='+query.b_id+'&s_id='+query.s_id)">
			添加店员
		</view>
		

  </view>
</template>

<script>
import Vue from 'vue';
export default Vue.extend({
  components: {},
  data() {
    return {
		query:{},
		style: {
			color: "#ff6344"
		},
		page:1,
		list:[]
	}
  },
  computed: {},
  methods: {
	initData(){
		this.request("ZhBusinesss/film_list", {
			...this.query,
			page:this.page

		}).then(res=>{
			try {
				this.list=this.page==1? res.data.data.data:[
					...this.list,
					...res.data.data.data
				]
			} catch (error) {
				
			}
		})
	},
	del(id, u_id=""){
		this.tips.choose("确定删除该员工吗？").then(res=>{
			if (res.code==200) {
				this.request("ZhBusinesss/film_del", {
					...this.query,
						id,
						u_id
					}).then(res => {
						if (res.data.status == 200) {
							this.tips.success(res.data.msg).then(res => {
								this.page = 1
								this.initData()
							})
						}
					})
			}
		})
	}
  },
  watch: {},

  // 页面周期函数--监听页面加载
  onLoad(options) {
	this.query=options
	this.initData()
  },
  // 页面周期函数--监听页面初次渲染完成
  onReady() {},
  // 页面周期函数--监听页面显示(not-nvue)
  onShow() {
	this.page=1
	this.initData()
  },
	// 页面周期函数--监听页面隐藏
	onHide() {},
	// 页面周期函数--监听页面卸载
	onUnload() {},
	// 页面处理函数--监听用户下拉动作
	// onPullDownRefresh() { uni.stopPullDownRefresh(); },
	// 页面处理函数--监听用户上拉触底
  	onReachBottom() {
		this.page += 1
		this.initData()
  	},
  // 页面处理函数--监听页面滚动(not-nvue)
  // onPageScroll(event) {},
  // 页面处理函数--用户点击右上角分享
  // onShareAppMessage(options) {},
}) 
</script>

<style scoped lang="scss">
	@import "./main.scss";
</style>